package com.gotloop.jdo;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.NullValue;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

/**
 * A Comment made on a Loop.
 * @author jibhaine
 *
 */
@PersistenceCapable
public class Comment {

	/**
	 * The commented Loop.
	 */
	@Persistent(mappedBy = "comments")
	private Loop loop;

	/**
	 * Public constructor.
	 * @param pLoop the commented Loop
	 */
	public Comment(Loop pLoop) {
		super();
		this.loop = pLoop;
	}

	/**
	 * Get accessor for loop.
	 * @return the loop to get
	 */
	public Loop getLoop() {
		return loop;
	}

	/**
	 * Set accessor for loop.
	 * @param pLoop the loop to set
	 */
	public void setLoop(Loop pLoop) {
		this.loop = pLoop;
	}

	/**
	 * Comment primary key.
	 */
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	/**
	 * User who wrote the comment.
	 */
	@Persistent
	private UserProfile author;

	/**
	 * Name for guest user.
	 */
	@Persistent
	private String name;

	/**
	 * Email for guest user.
	 */
	@Persistent
	private String email;

	/**
	 * WebSite for guest user.
	 */
	@Persistent
	private String site;

	/**
	 * Comment content.
	 */
	@Persistent(nullValue = NullValue.NONE)
	private String content;

	/**
	 * True if comment is published.
	 */
	@Persistent
	private boolean published;

	/**
	 * Date of Comment Creation.
	 */
	@Persistent
	private Date creationDate;

	/**
	 * Date of comment modification.
	 */
	@Persistent
	private Date modificationDate;

	/**
	 * Get accessor for key.
	 * @return the id to get
	 */
	public Key getKey() {
		return key;
	}

	/**
	 * Set accessor for key.
	 * @param pKey the id to set
	 */
	public void setKey(Key pKey) {
		this.key = pKey;
	}

	/**
	 * Get accessor for author.
	 * @return the author to get
	 */
	public UserProfile getAuthor() {
		return author;
	}

	/**
	 * Set accessor for author.
	 * @param pAuthor the author to set
	 */
	public void setAuthor(UserProfile pAuthor) {
		this.author = pAuthor;
	}

	/**
	 * Get accessor for name.
	 * @return the name to get
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set accessor for name.
	 * @param pName the name to set
	 */
	public void setName(String pName) {
		this.name = pName;
	}

	/**
	 * Get accessor for email.
	 * @return the email to get
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * Set accessor for email.
	 * @param pEmail the email to set
	 */
	public void setEmail(String pEmail) {
		this.email = pEmail;
	}

	/**
	 * Get accessor for site.
	 * @return the site to get
	 */
	public String getSite() {
		return site;
	}

	/**
	 * Set accessor for site.
	 * @param pSite the site to set
	 */
	public void setSite(String pSite) {
		this.site = pSite;
	}

	/**
	 * Get accessor for content.
	 * @return the content to get
	 */
	public String getContent() {
		return content;
	}

	/**
	 * Set accessor for content.
	 * @param pContent the content to set
	 */
	public void setContent(String pContent) {
		this.content = pContent;
	}

	/**
	 * Get accessor for published.
	 * @return the published to get
	 */
	public boolean isPublished() {
		return published;
	}

	/**
	 * Set accessor for published.
	 * @param pPublished the published to set
	 */
	public void setPublished(boolean pPublished) {
		this.published = pPublished;
	}

	/**
	 * Get accessor for creationDate.
	 * @return the creationDate to get
	 */
	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * Set accessor for creationDate.
	 * @param pCreationDate the creationDate to set
	 */
	public void setCreationDate(Date pCreationDate) {
		this.creationDate = pCreationDate;
	}

	/**
	 * Get accessor for modificationDate.
	 * @return the modificationDate to get
	 */
	public Date getModificationDate() {
		return modificationDate;
	}

	/**
	 * Set accessor for modificationDate.
	 * @param pModificationDate the modificationDate to set
	 */
	public void setModificationDate(Date pModificationDate) {
		this.modificationDate = pModificationDate;
	}
}
